package com.ooolong.expression.operator;

import com.ooolong.expression.ExpressionException;
import com.ooolong.expression.OObject;

public class Divide extends Operator {

	public Divide() {
		super("/", 6, true);
		this.type = OObject.DIVIDE;
	}

	@Override
	public OObject execute(OObject[] args) throws ExpressionException {
		checkArguments(args);

		OObject leftOprand = args[0];
		OObject rightOprand = args[1];
		Double res = leftOprand.toDouble() / rightOprand.toDouble();
		return OObject.newInstance(res);
	}
}
